import { Controller, Get, HttpCode, Query, UseGuards } from "@nestjs/common";
import { JwtService } from "@nestjs/jwt";
import { ApiBearerAuth, ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
import { OperationRecordService } from "./operation-record.service";
import { OperationRecordResult } from "./entities/operation-record.entity";
import { AuthGuard } from "@nestjs/passport";
import { GetOperationRecordPageDto } from "./dto/operation-record.dto";

@ApiBearerAuth() // swagger文档设置token
@ApiTags('操作记录')
@Controller('admin/operation-record')
export class OperationRecordController {
    constructor(
        private readonly operationRecordService: OperationRecordService,
        private readonly jwtService: JwtService,
    ) { }
    /** 操作记录 */
    @HttpCode(200)
    @Get('/getOperationRecordPage')
    @ApiResponse({
        status: 200,
        description: '操作记录',
        type: OperationRecordResult,
    })
    @ApiOperation({
        tags: ['获取操作记录'],
        summary: '获取操作记录',
        operationId: 'getOperationRecordPage',
    })
    @UseGuards(AuthGuard('jwt')) // 自定义守卫
    getOperationRecordPage(@Query() params: GetOperationRecordPageDto) {
        return this.operationRecordService.getOperationRecordPage(params);
    }
}